[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
chown(LIST)
chown LIST
Changes the owner (and group) of a list of files.
The first two elements of the list must be the
NUMERICAL uid and gid, in that order. Returns the
number of files successfully changed.
$cnt = chown $uid, $gid, 'foo', 'bar';
chown $uid, $gid, @filenames;
Here's an example that looks up non-numeric uids in
the passwd file:
print "User: ";
$user = <STDIN>;
chop($user);
print "Files: "
$pattern = <STDIN>;
chop($pattern);
open(pass, '/etc/passwd')
|| die "Can't open passwd: $!\n";
while (<pass>) {
($login,$pass,$uid,$gid) = split(/:/);
$uid{$login} = $uid;
$gid{$login} = $gid;
}
@ary = <${pattern}>; # get filenames
if ($uid{$user} eq '') {
die "$user not in passwd file";
}
else {
chown $uid{$user}, $gid{$user}, @ary;
}
See Also:
chmod
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson